#####################################################################
# File:         __init__.py
# Library:      KnowledgeEngine.Editlets
#
# Copyright:    Copyright (c) 2002, Faulker Ltd.
# Author:       Brian Oliver
#
# Description:  This file initialises the KnowledgeEngine Editlets
#               Packag, used for constructing property editors
#####################################################################

#####################################################################
## Knowledge Engine Library Imports
# (none - done automatically. see below)

#####################################################################
## Zope Library Imports
from App.FindHomes import ppath

#####################################################################
## Python Library Imports
import os
    
#####################################################################    
## Import the KnowledgeEngine Editlets
##
## Each KnowledgeEngine Editlet resides in single *Editlet.py file
## (named after the editlet) within the Editlets folder
## in the KnowledgeEngine Zope Product
##
## By individually importing each editlet, they have a chance of
## performing their own initialisation, including appropriately
## registering themselves as part of the KnowledgeEngine product.

# The path to the KnowledgeEngine Editlets Package
EDITLETS_PATH = ppath[0] + os.sep + "KnowledgeEngine" + os.sep + "Editlets"

# Dynamically import each of the defined Editlets in the EDITLETS_PATH
for editlet in [file for file in os.listdir(EDITLETS_PATH) if os.path.isdir(EDITLETS_PATH + os.sep + file)]:

    # Import the current editlet (if it doesn't contain a .)
    if editlet.find(".") < 0:
        print "[KnowledgeEngine] Registering Editlet: " + editlet

        exec "from Products.KnowledgeEngine.Editlets." + editlet + " import *"

#####################################################################    
